﻿using System;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        lUser.Text = User.Identity.Name;


        UmSoft.SharePoint.Integration.Bdc.Core.Sattings s = new UmSoft.SharePoint.Integration.Bdc.Core.Sattings();
        for(int i=1; i<=s.GetCountReports();i++)
        {
            System.Web.UI.WebControls.ListItem li=new System.Web.UI.WebControls.ListItem(s.GetDisplayNameReport(i),s.GetNameReport(i));
            reportName.Items.Add(li);
        }
        dateEnd1.VisibleDate = System.DateTime.Now;
        dateStart1.VisibleDate = System.DateTime.Now;



        //s.GetAttribute(reportName, "path_ERT");

        //System.IO.FileInfo fi =new System.IO.FileInfo("");
        //System.Security.AccessControl.FileSecurity fs = fi.GetAccessControl();
        //System.Security.AccessControl.AuthorizationRuleCollection col =  fs.GetAccessRules(false, false, System.Security.Principal.SecurityIdentifier);
        //col[1].IdentityReference.Value;
        //System.Security.Principal.
        //System.Security.AccessControl.FileSecurity fs= System.IO.File.GetAccessControl(s.GetAttribute(reportName, "path_ERT"), System.Security.AccessControl.AccessControlSections.Access);
        //fs.GetAccessRules(false,false,
        
    }

    protected void dateStart_SelectionChanged(object sender, EventArgs e)
    {
    }
    protected void dateEnd_SelectionChanged(object sender, EventArgs e)
    {
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Button2.Enabled = false;
        string SERVER_NAME = Request.ServerVariables["SERVER_NAME"].ToString();

        dateStart.Value = dateStart1.SelectedDate.ToString("MM-dd-yyyy");
        dateEnd.Value = dateEnd1.SelectedDate.ToString("MM-dd-yyyy");
        SERVER_NAME = "http://" + SERVER_NAME + "/Service1C/ServiceV77.asmx/GetReport?dateStart=" +
             dateStart1.SelectedDate.ToString("MM-dd-yyyy") + "&dateEnd=" + dateEnd1.SelectedDate.ToString("MM-dd-yyyy") + "&reportName=" + reportName.Text;
        Response.Redirect(SERVER_NAME);

    }


    protected void dateStart1_DateChanged(object sender, EventArgs e)
    {
        dateStart.Value = dateStart1.SelectedDate.ToString("MM-dd-yyyy");

        string SERVER_NAME = Request.ServerVariables["SERVER_NAME"].ToString();
        myform.Attributes["action"] = "http://" + SERVER_NAME + "/Service1C/ServiceV77.asmx/GetReport?dateStart=" +
             dateStart1.SelectedDate.ToString("MM-dd-yyyy") + "&dateEnd=" + dateEnd1.SelectedDate.ToString("MM-dd-yyyy") + "&reportName=" + reportName.Text;
    }
    protected void dateEnd1_DateChanged(object sender, EventArgs e)
    {
        dateEnd.Value = dateEnd1.SelectedDate.ToString("MM-dd-yyyy");

        string SERVER_NAME = Request.ServerVariables["SERVER_NAME"].ToString();
        myform.Attributes["action"] = "http://" + SERVER_NAME + "/Service1C/ServiceV77.asmx/GetReport?dateStart=" +
             dateStart1.SelectedDate.ToString("MM-dd-yyyy") + "&dateEnd=" + dateEnd1.SelectedDate.ToString("MM-dd-yyyy") + "&reportName=" + reportName.Text;
    }
}
